package com.java_foundation.singleton;

import java.io.IOException;
import java.util.Properties;

/**
 * @program: java_foundation
 * @description: 静态代码块的单例
 * @author: xiongbangwen <Email>xiongbangwen@163.com</Email>
 * @create: 2020-05-30 20:52
 **/
public class Singleton_3 {

    public static final Singleton_3 INSTANCE;
    private String info;

    static {
        try {
            Properties pro = new Properties();

            pro.load(Singleton_3.class.getClassLoader().getResourceAsStream("singleton.properties"));

            INSTANCE = new Singleton_3(pro.getProperty("info"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    private Singleton_3(String info){
        this.info = info;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    @Override
    public String toString() {
        return "Singleton_3{" +
                "info='" + info + '\'' +
                '}';
    }
}
